<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
<button id="button"></button>
<script>

    var button=document.getElementById("button")
    button.onclick=function () {
        newdiv = document.createElement('div')
        newdiv.id = 'NewDiv'
        document.body.appendChild(newdiv)

        function O(i) {
            return typeof i == 'object' ? i : document.getElementById(i)
        }

        function S(i) {
            return O(i).style
        }

        S(newdiv).border = '1px solid red'
        S(newdiv).width = '400px';
        S(newdiv).height = '400px'
        newdiv.innerHTML = "this is a new div"
        newbutton=document.createElement('button')
        newbutton.id='Newbutton'
        newdiv.appendChild(newbutton);
        newbutton.onclick=function () {
            alert("动态添加")
        }



    }
</script>
</body>
</html>